package yja.gzw.app.activity

import android.util.Log
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.ChujiaAdapter
import yja.gzw.app.adapter.XiaoxiAdapter
import yja.gzw.app.base.BaseActivity
import yja.gzw.app.databinding.ActivityXiatongxiaoxiBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.viewmodel.Mainviewmodel

class XiatongxiaoxiActivity :BaseActivity<Mainviewmodel, ActivityXiatongxiaoxiBinding>(R.layout.activity_xiatongxiaoxi){

    private lateinit var neituada: XiaoxiAdapter
    override fun initView() {
        UserData.kan=true
        binding.fanhui.setOnClickListener {
            finish()
        }

        viewmodel.onxitongxiaoxiwang(UserData.token)


    }

    override fun dataObservese() {
        viewmodel.onxitongxiaoxi.observe(this, Observer {
            if(it.code==1){

                binding.review.layoutManager=
                    LinearLayoutManager(this)
                neituada= XiaoxiAdapter(this,it.data.data)
                binding.review.adapter= neituada

            }else{
                Toast.makeText(this,it.msg, Toast.LENGTH_SHORT).show()

            }

        })


    }


}